import { Component ,Input ,Output,EventEmitter,} from '@angular/core';
import { Router } from '@angular/router';

/**
 * 后台管理视频页标签编辑组件
 * @example
 * 示例：视频管理编辑页面，用该组件渲染出用户数据列表
 * 输入属性：{object} video 
 * 输出属性：delete 向父组件deleteVideoVideo($event)方法传参
 * 输出属性：edit 向父组件editVideo($event)方法传参
 * 输出属性：restore 向父组件deleteVideoVideo($event,true)方法传参
 * <ng-video-card *ngFor="let video of VideoList" 
 *  [video]="video"
 *    (delete)="deleteVideo($event)"
 *    (edit)="editVideo($event)"
 *    (restore)="deleteVideo($event,true)">
 *  </ng-video-card>
 */
@Component({
  selector: 'ng-video-card',
  templateUrl: './video-card.component.html',
  styleUrls: ['./video-card.component.scss']
})
export class VideoCardComponent {


  /**
   * 从父组件传入绑定的对象数据值
   * @type Object
   * @example
   * [video]="video"
   */
  @Input("video")
  video:any={}

  /**
   * 向父组件传参
   */
  @Output("edit")
  _edit:EventEmitter<any> = new EventEmitter()

  @Output("delete")
  _delete:EventEmitter<any> = new EventEmitter()

  @Output("restore")
  _restore:EventEmitter<any> = new EventEmitter()



  constructor(private router:Router){
 
  }

  delete(){
    this._delete.emit(this.video)
  }

  /**
   * 跳转到"/admin-bvideo/videoedit"页面
   * 并传出vidoe的objectId属性到对应组件
   */
  edit(){
    this.router.navigate(["/admin-bvideo/videoedit"],{
      queryParams:{
        id:this.video.objectId
      }
    })  
  }

  /**
   * 跳转到"/admin-bvideo/commentlist"页面
   * 并传出vidoe的objectId属性到对应组件
   */
  comment(){
    this.router.navigate(["/admin-bvideo/commentlist"],{
      queryParams:{
        id:this.video.objectId,
      }
    })  
  }

  restore(){
    this._restore.emit(this.video)
  }

}
